#!/bin/bash
# Computes simple pileup for each file in folder.
# parameters.
indir=$1
outdir=$2

function pileup {
	# make name.
	outname1=$(basename $1 .bam).pileup
	
	# Call pileup.
	samtools mpileup -B $1 | awk '{printf("%s\t%i\t%i\n", $1, $2, $4);}' > ${outdir}/${outname1}
}

# Loop over indir.
for x in $(ls ${indir}/*bam); do
	# call function.
	pileup $x &
done;
